<?php
$server = new swoole_server("192.168.2.118", 9504);
$server->on('connect', function ($server, $fd){//链接上了
    echo "connection open: {$fd}\n";
});
$server->on('receive', function ($server, $fd, $reactor_id, $data) {
    $commanld = $data;
    $commanld = str_replace('~',' ',$commanld);
    $res = exec($commanld);
    $server->send($fd, "Swoole: {$res}");
    $server->close($fd);
    $server->shutdown();
});
$server->on('close', function ($server, $fd) {
    echo "connection close: {$fd}\n";
});
$server->start();
